#!/bin/env perl

use strict;
use warnings;

# print length(@ARGV);
print @ARGV;

# die "genome_window.pl <genome_length_file> <out.bed>\n\ta row of genome_length_file like \n\tchr1\t1\t2000000\n" if length(@ARGV) < 2;

my $win_size = 200000;

open LEN, "$ARGV[0]";
open WIN, '>', "$ARGV[1]";



while (<LEN>) {
	chomp;
	my @chr_len = split;
	my $win_num = sprintf "%d", $chr_len[1] / $win_size;
	my $start;
	my $end;
	foreach (1..$win_num-1) {
	
		$start = $win_size * ($_ - 1) + 1;
		$end = $win_size * $_;
		print WIN "$chr_len[0]\t$start\t$end\n";
	}
	$start = $win_size * $win_num + 1;
	$end = $chr_len[1];
	print WIN "$chr_len[0]\t$start\t$end\n";
	
}

close LEN;
close WIN;







